Repository navigation
fix(client): resolve SSE endpoint URL and origin against redirected response URL - #3241
kingroyale537 wants to merge 2 commits into
Conversation
|
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
|
The fix is right for the default policy, but the endpoint origin guard changes its reference under Before, Reproduced against this branch, with the transport configured at server A: A answers #3240's author proposed using the final I'm not arguing the wider bound is wrong under Separately, |
|
I checked the path-resolution part against both released All cases started at
The new test in this PR uses a leading-slash endpoint on another origin under This verifies the path behavior only; it does not resolve the separate |
|
Good catch @SyedTashfin and @Pablo-aps — updated in
|
|
One correction to my comment above, because it matters for how the guard is reviewed. I wrote that "nothing in What I should have written: the accepting side is covered by the new test, the rejecting side is not. Thanks for turning this around, and to @Pablo-aps for checking the path behaviour independently. |
|
Thanks both for checking and verifying the redirect/origin cases @SyedTashfin @Pablo-aps! |
|
I reran the localhost check against the updated This rerun covered same-origin path resolution with no auth and no external server. |
Fixes #3240.
When
SSEClientTransportfollows a redirect during the GET handshake (e.g.redirectPolicy: 'follow'),this._urlstill holds the pre-redirect URL, causing relativeendpointevents to resolve against the original origin and fail the same-origin check.Track the final
response.urlfrom the EventSourcefetchcallback and resolve/validateendpointevents against it, falling back tothis._urlif absent.